/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package app;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author macbookpro
 */
public abstract class FBase extends JFrame implements ActionListener {
    protected GridBagConstraints restricoes = new GridBagConstraints();
    protected JButton	btnOk, btnCancela;
    protected JPanel pnlDados = new JPanel();
    protected JPanel pnlBotoes = new JPanel();
    protected JPanel pnlJanela = new JPanel();
    protected JLabel lblTitulo;

    public FBase() {
        addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                dispose();
            }
        });
        setSize(300, 230);
        setLocation(0, 0);
        setTitle("Sistema de Pendencias");
        setResizable(false);

      
		//pnlDados = new JPanel(); //onde ficam os componentes nos frames filhos
		pnlDados.setLayout(new GridBagLayout());
        
		//pnlBotoes = new JPanel();
		pnlBotoes.setLayout(new GridBagLayout());

		btnOk = new JButton("Ok");
		restricoes.gridx = 0; // define coluna
		restricoes.gridy = 0; // define linha
		restricoes.insets = new Insets(0, 0, 0, 10);
		pnlBotoes.add(btnOk, restricoes);

		btnCancela = new JButton("Cancelar");
		restricoes.gridx = 1; // define coluna
		restricoes.insets = new Insets(0, 0, 0, 10);
		pnlBotoes.add(btnCancela, restricoes);
        pnlBotoes.setBorder(BorderFactory.createEtchedBorder());

/*
        JPanel pnlLabelMalComportado = new JPanel();
        pnlLabelMalComportado.setLayout(new GridBagLayout());
        restricoes.gridx = 0;
        restricoes.gridy = 0;
        restricoes.anchor = GridBagConstraints.CENTER;
        pnlLabelMalComportado.add(lblTitulo,restricoes);
        */
        pnlJanela.setLayout(new BorderLayout());
        //pnlJanela.add(lblTitulo,BorderLayout.NORTH);
        //pnlJanela.add(pnlLabelMalComportado,BorderLayout.NORTH);
        pnlJanela.add(pnlDados, BorderLayout.CENTER);
        pnlJanela.add(pnlBotoes, BorderLayout.SOUTH);

        Container P = getContentPane();
		P.add(pnlJanela);

        btnCancela.addActionListener(this);
        btnOk.addActionListener(this);
    }

    public void actionPerformed(ActionEvent e) {
        Object origem = e.getSource();

        if (origem == btnCancela){
            btnCancelaClick();
        }

        if (origem == btnOk){
            btnOkClick();
        }
    }

    public void btnCancelaClick(){  //fica opcional dar override
        dispose();
    }
    public abstract void btnOkClick();
}
